<?php
########################################################################################
# Empresa :     Tecnopac Informatica;                                                  #
# Autor:        Deiverson Pacheco;                                                     #
# Data Criação: 18/12/2010;                                                            #
########################################################################################
session_start();
header("Cache-control: private");
include_once("../../includes/session.php");


//Linha para formatação de caracteres com acentuação
header("Content-Type: text/html; charset=ISO-8859-1",true);


//======================================================================================
//==> Include obrigatórias no script
//======================================================================================
include_once('../../includes/classes/class.TemplatePower.php');
include_once('../../includes/classes/class.Conexao.php');
include_once('../../includes/classes/class.Geral.php');

//======================================================================================
//==> Inicializar Classes
//======================================================================================
$not  = new Persist;
$data = new getData;
$cor  = new ColorTr;
$util = new Util;
$vld  = new ValidarDados;
$sql  = new SqlInjection;

//======================================================================================
//==> Instanciar TemplatePower para juntar o PHP + HTML
//======================================================================================
$tpl  = new TemplatePower('../../html/relatorio/popup_listagem_contato.html');
$tpl->prepare();


//======================================================================================
//==> Recebe variaveis de pesquisa
//======================================================================================
$busca  = @$_GET['busca'];

$sql_busca = '';
if($busca != ''){
   $busca = $sql->tratar($busca,50);
   $sql_busca = " and categoria like '%$busca%' ";
}

$cont   = 1;
$not->sql = "select id, categoria, ativo from categorias where ativo = 'Sim' $sql_busca order by categoria asc";

if($not->ler()>0){
	while($not->ini()){
		$tpl->newBlock('LOOP');
		$tpl->assign('cont',$cont);
		$cont++;
		$tpl->assign('id', $not->id);
		$tpl->assign('par_id',$not->id);
		$tpl->assign('nome', $not->categoria);
		$tpl->assign('ativo', $not->ativo);
		$tpl->assign('cor', $cor->altColor());


	}
}



$tpl->goToBlock('_ROOT');

//======================================================================================
//==> Enviar página unificada PHP + HTML
//======================================================================================
$tpl->showUnAssigned( false );  // para debug. na hora de publicar, setar para false
$tpl->printToScreen();
?>